/*
 * FilterSet
 * 
 * Copyright 2011 Matt Whipple <matt@mattwhipple.com>
 * 
 * This file is part of com.teamsuperfitness.apps
 * 
 * com.teamsuperfitness.apps is free software: you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your option)
 * any later version.
 * 
 * com.teamsuperfitness.apps is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with com.teamsuperfitness.apps. If not, see http://www.gnu.org/licenses/.
 */

package com.teamsuperfitness.apps.shared.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@SuppressWarnings("serial")
public class FilterSet implements Serializable {

	public Map<String,Filter> filters = new HashMap<String,Filter>();
	
	public void setFilter(String id, String property, String operator, String value) {
		Filter newFilter = new Filter();
		newFilter.property = property;
		newFilter.value = value;
		newFilter.operator = operator;
		filters.put(id, newFilter);
	}
	
	public List<Filter> getList() {
		ArrayList<Filter> result = new ArrayList<Filter>();
		if (filters == null || filters.isEmpty()) {
			return result;
		}
		
		for (Map.Entry<String, Filter> entry : filters.entrySet()) {
			result.add(entry.getValue());
		}
		return result;
	}
	
	public void SetFilter(Filter filter) {
		filters.put(filter.id, filter);
	}
	
}
